import requests
import re
from urllib3.exceptions import InsecureRequestWarning
import datetime

# 禁用安全请求警告
Platform = "好书云"
today = datetime.date.today()  # 今天
yester = today - datetime.timedelta(days=1)


def haoshuyun():
    try:
        requests.urllib3.disable_warnings(InsecureRequestWarning)
        r = requests.session()
        data = {
            "username": "",
            "password": ""
        }
        rr = r.post(url="http://book.zhihaoyun.com/novel.php/user/publics/signin", data=data, verify=False, timeout=15)
        ht = r.get(url='http://book.zhihaoyun.com/novel.php/agent/statistical/paylog', verify=False, timeout=15)
        ht = ht.text.replace('\r', '').replace('\t', '').replace('\n', '')
        Amount_share_list = re.findall('<td class="">\s+(\d+\.\d+)\s+</td>', ht)
        Amount_share = Amount_share_list[1]
        Amount_share = round(float(Amount_share) * 0.9, 2)
        date_time = str(yester)
        return date_time, Amount_share, Platform
    except Exception:
        print('获取 好书云 数据失败')
        return '', 'None', Platform
    except ConnectionError:
        print("获取 好书云 数据 超时")
        return '', 'None', Platform